package cn.elwy.rcp.kit.handlers;

import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;

/**
 * 切换主题的实现类
 * @author huangsq
 */
public class SwitchThemeHandler {
	private boolean reset = false;
	private final static String USER_CSS_DEFAULT = "cn.elwy.rcp.kit.default";
	private final static String USER_CSS_RAINBOW = "cn.elwy.rcp.kit.rainbow";

	@Execute
	public void execute(IThemeEngine engine) {
		if (reset) {
			engine.setTheme(USER_CSS_RAINBOW, true);
		} else {
			engine.setTheme(USER_CSS_DEFAULT, true);
		}
		reset = !reset;
	}

	@CanExecute
	boolean canExecute() {
		return true;
	}

}